package com.mvc.dao;

import com.mvc.pojo.Student;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class StudentDAO {
    //模拟从数据库中取数据
    static List<Student> list = new ArrayList<>();

    static {
        list.add(new Student(1, "张三", 10));
        list.add(new Student(2, "张三2", 101));
        list.add(new Student(3, "张三3", 102));
        list.add(new Student(4, "张三4", 103));
        list.add(new Student(5, "张三5", 104));
        list.add(new Student(6, "张三6", 105));
        list.add(new Student(7, "张三7", 106));
    }

    //模拟从数据库中查询数据
    public List<Student> getAllStudent() {
        return list;
    }
    //模拟插入数据
    public void addStudent(Student student) {
        list.add(student);
    }
}
